﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using AutoInsurance.Classes;
using System.Data.SqlClient;
using System.Data.SqlTypes;

namespace AutoInsurance
{
    public partial class customerData : System.Web.UI.Page
    {
        private string Сonn = @"Data Source=LOCALHOST\SQLEXPRESS;Initial Catalog=Autoinsurance;
Integrated Security=True;Pooling=False";

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SqlConnection sqlCon = new SqlConnection(Сonn);
                sqlCon.Open();
                string strQuery = "SELECT * FROM Client ";
                DataSet ds = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter();
                da.SelectCommand = new SqlCommand(strQuery, sqlCon);
                da.Fill(ds, "Клиенты");
                GridView1.DataSource = ds.Tables["Клиенты"];
                this.DataBind();
                sqlCon.Close();
            }
            catch (Exception ex)
            {
                Server.Transfer("Error.aspx?error=" + ex.Message);
            }
           
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int id_client = (int)GridView1.SelectedDataKey.Values["id_client"];

                string myUrl = "autoData.aspx?IDCLIENT=" + id_client;
                Response.Redirect(myUrl);
            }
            catch (Exception ex)
            {
                Server.Transfer("Error.aspx?error=" + ex.Message);
            }
        }

        
    }
}